package com.zhuss.team.processor;

import com.zhuss.bean.bo.team.invest.DeleteInvestQuestionBo;
import com.zhuss.common.AbstractProcessor;
import com.zhuss.common.Processor;
import com.zhuss.db.entity.OpLog;
import com.zhuss.enums.EnumUtil;
import com.zhuss.enums.LogActionEnum;
import com.zhuss.enums.MoudleEnum;
import com.zhuss.enums.RolePermissionDeleteType;
import com.zhuss.exception.WpsException;
import com.zhuss.team.db.dao.ext.InvestQuestionDao;
import com.zhuss.util.JsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

/**
 * @Author: zhushanshuo
 * @Date: 2020/3/30 14:15
 */
@Component("investQuestionDelete")
public class InvestQuestionDelete extends AbstractProcessor<Object, DeleteInvestQuestionBo> implements Processor<Object, DeleteInvestQuestionBo> {

    @Autowired
    private InvestQuestionDao investQuestionDao;

    @Override
    public Object process(DeleteInvestQuestionBo bo) throws WpsException {
        Long investId = bo.getInvestId();
        List<Long> questionIdList = bo.getQuestionIdList();
        investQuestionDao.deleteByInvestQuestion(bo, investId, questionIdList);
        return null;
    }

    @Override
    public Object log(DeleteInvestQuestionBo param) throws WpsException {
        OpLog record = new OpLog();
        record.setMoudle(MoudleEnum.协同发布.key());
        record.setAction(LogActionEnum.问卷问题关系解除.key());
        record.setTargetId(param.getInvestId());
        record.setContent("参数: " + JsonUtil.toJson(param));
        record.setReason(param.getExceptionReason());

        record.setCreatorId(param.getConcurrentUserId());
        record.setCreator(param.getConcurrentUserName());
        record.setCreateTime(new Date());
        log(record);
        return null;
    }

    @Override
    public void check(DeleteInvestQuestionBo deleteInvestQuestionBo) throws WpsException {

    }
}
